﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

public class LightObject:MissionObject
{
    protected new LightObject.Type thisType;

    /**
     * creates a CollidableObject at 'placement' of type 'type'.
     * initializes origin, and
     * type. This will set the SpawnPointer for this instance
     * to null.
     * @param type an instance of ObjectFactory.TypeEnum which
     * specifies what type of CollidableObject to create
     * @param placement the world x,y,z coordinates that define
     * where this instance is placed.
     * @see ObjectFactory.TypeEnum
     */
    public LightObject(LightObject.Type type, Vector3 placement)
        : base(type, placement)
    {
    }

    public new class Type : MissionObject.Type
    {
        //lightweight objects:

        public static readonly Type Television = new Type(
            ObjectFactory.TypeEnum.Television,//type
            new Vector3(45, 58, 0),//origin
            new Vector3(91, 58, 48),//collision
            new ArrayList { 
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("tv"), 
                    new Rectangle(0, 0, 91, 62), 
                    0, 
                    new Vector2(45, 58)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("tv"), 
                    new Rectangle(91, 0, 91, 62), 
                    0, 
                    new Vector2(45, 58)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("tv"), 
                    new Rectangle(182, 0, 91, 62), 
                    0, 
                    new Vector2(45, 58)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("tv"), 
                    new Rectangle(273, 0, 91, 62), 
                    0, 
                    new Vector2(45, 58)),
                new Frame(
                        Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("tv"), 
                        new Rectangle(0, 0, 91, 62), 
                        0, 
                        new Vector2(45, 58)),
                new Frame(
                        Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("tv"), 
                        new Rectangle(182, 0, 91, 62), 
                        0, 
                        new Vector2(45, 58)),
                new Frame(
                        Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("tv"), 
                        new Rectangle(91, 0, 91, 62), 
                        0, 
                        new Vector2(45, 58)),
                new Frame(
                        Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("tv"), 
                        new Rectangle(273, 0, 91, 62), 
                        0, 
                        new Vector2(45, 58))},

            new ArrayList { 
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("tv"), 
                    new Rectangle(0, 0, 91, 62), 
                    0, 
                    new Vector2(45, 58))});//frameList

        public static readonly Type Laptop = new Type(//315x90
            ObjectFactory.TypeEnum.Laptop,//type
            new Vector3(22, 45, 0),//origin
            new Vector3(45, 45, 40),//collision
            false,//walkable
            new ArrayList { 
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(0, 0, 45, 45), 
                    3, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(45, 0, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(90, 0, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(135, 0, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(180, 0, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(225, 0, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(270, 0, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(0, 45, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(45, 45, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(90, 45, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(135, 45, 45, 45), 
                    0, 
                    new Vector2(22, 45)),
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(180, 45, 45, 45), 
                    4, 
                    new Vector2(22, 45))},//stasis frames
            "laptopStasis",//stasis name
            3,//stasis framerate
            true,//stasis loopable
            new ArrayList { 
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("laptopSpriteSheet"), 
                    new Rectangle(225, 45, 45, 45), 
                    0, 
                    new Vector2(22, 45))},//explosion frames
            "laptopExplosion",//explosion name
            3,//explosion framerate
            false);//explosion loopable

        public static readonly Type Toaster = new Type();
        public static readonly Type Dish = new Type();
        public static readonly Type Rotor = new Type();
        public static readonly Type Bear = new Type(
            ObjectFactory.TypeEnum.Bear,//type
            new Vector3(31, 64, 0),//origin
            new Vector3(63, 64, 40),//collision
            new ArrayList { 
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("bear"), 
                    new Rectangle(0, 0, 63, 64), 
                    0, 
                    new Vector2(31, 64))},
            new ArrayList { 
                new Frame(
                    Game.getGame().getAssetLibrary().get(AssetLibrary.assetType.MISSION_OBJECT).get("bear"), 
                    new Rectangle(0, 0, 63, 64), 
                    0, 
                    new Vector2(31, 64))});

        //actual class data

        /**
         * this is a dummy constructor.
         */
        protected Type() { }

        /**
         * Private constructor.
         * This private constructor ensures that only 
         * the pre-specified Type objects can be used 
         * and compared against.
         * @param origin
         * @param collision
         * @param basic
         * @param destruction
         */
        protected Type(ObjectFactory.TypeEnum type, Vector3 origin, Vector3 collision, Boolean walkable,
            ArrayList stasisFrames, String stasisName, int stasisFramerate, Boolean stasisLoopable,
            ArrayList explosionFrames, String explosionName, int explosionFramerate, Boolean explosionLoopable)
            : base(type, origin, collision, walkable, stasisFrames, stasisName, stasisFramerate, stasisLoopable,
            explosionFrames, explosionName, explosionFramerate, explosionLoopable)
        {
        }

        protected Type(ObjectFactory.TypeEnum type, Vector3 origin, Vector3 collision,
            ArrayList stasisFrames, ArrayList explosionFrames)
            : base(type, origin, collision, stasisFrames, explosionFrames)
        {
        }

        public static new LightObject.Type getType(ObjectFactory.TypeEnum type)
        {
            switch(type)
            {
                case ObjectFactory.TypeEnum.Television: return Television;
                case ObjectFactory.TypeEnum.Laptop: return Laptop;
                case ObjectFactory.TypeEnum.Toaster: return Toaster;
                case ObjectFactory.TypeEnum.Dish: return Dish;
                case ObjectFactory.TypeEnum.Rotor: return Rotor;
                case ObjectFactory.TypeEnum.Bear: return Bear;
            }
            return null;
        }
    }
}
